package gov.pbc.nn.core.bdf.entity;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.bstek.bdf2.core.business.AbstractUser;
import com.bstek.bdf2.core.business.IDept;
import com.bstek.bdf2.core.business.IPosition;
import com.bstek.bdf2.core.model.Group;
import com.bstek.bdf2.core.model.Role;
import com.bstek.dorado.annotation.PropertyDef;

/**
 * @author caoguojin
 *
 */
@Entity
@Table(name = "T_USER")
public class User extends AbstractUser implements java.io.Serializable {
	// 用户名、密码、姓名、英文名、邮箱、手机、所属单位、性别、身份证号、出生日期
	private static final long serialVersionUID = 1L;
	@Id
	@Column(name = "USERNAME_", length = 60)
	@PropertyDef(label = "用户名")
	private String username;
	@Column(name = "PASSWORD_", length = 70, nullable = false)
	@PropertyDef(label = "密码")
	private String password;
	@Column(name = "SALT_", length = 10)
	private String salt;
	@Column(name = "CNAME_", length = 60, nullable = false)
	@PropertyDef(label = "中文名字")
	private String cname;
	@Column(name = "ENAME_", length = 60)
	@PropertyDef(label = "英文名字")
	private String ename;
	@Column(name = "MALE_")
	@PropertyDef(label = "性别")
	private boolean male = true;
	@Column(name = "ENABLED_")
	@PropertyDef(label = "是否可用")
	private boolean enabled = true;
	@Column(name = "ADMINISTRATOR_")
	@PropertyDef(label = "管理员")
	private boolean administrator = false;
	@Column(name = "BIRTHDAY_")
	@PropertyDef(label = "出生日期")
	private Date birthday;
	@Column(name = "MOBILE_", length = 120)
	@PropertyDef(label = "联系方式")
	private String mobile;
	@Column(name = "ADDRESS_", length = 120)
	@PropertyDef(label = "地址")
	private String address;
	@Column(name = "EMAIL_", length = 60)
	@PropertyDef(label = "邮箱")
	private String email;
	@Column(name = "COMPANY_ID_", length = 60, nullable = false)
	@PropertyDef(label = "公司ID")
	private String companyId;
	@Column(name = "CREATE_DATE_")
	@PropertyDef(label = "创建日期")
	private Date createDate;
	@Column(name = "IDENTITY_", length = 60)
	@PropertyDef(label = "身份证")
	private String identity;
	@Column(name = "DUTY_", length = 120)
	@PropertyDef(label = "职位")
	private String duty;
	@Column(name = "FK_SYS_NAME_", length = 120)
	private String fkSysName;
	@Transient
	private List<IPosition> positions;
	@Transient
	private List<IDept> depts;
	@Transient
	private List<Group> groups;
	@Transient
	private List<Role> roles;

	public User() {
	}

	public User(String username) {
		this.username = username;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	public String getEname() {
		return ename;
	}

	public void setEname(String ename) {
		this.ename = ename;
	}

	public boolean isMale() {
		return male;
	}

	public void setMale(boolean male) {
		this.male = male;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public boolean isAdministrator() {
		return administrator;
	}

	public void setAdministrator(boolean administrator) {
		this.administrator = administrator;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getIdentity() {
		return identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}

	public List<IPosition> getPositions() {
		return positions;
	}

	public void setPositions(List<IPosition> positions) {
		this.positions = positions;
	}

	public List<IDept> getDepts() {
		return depts;
	}

	public void setDepts(List<IDept> depts) {
		this.depts = depts;
	}

	public List<Group> getGroups() {
		return groups;
	}

	public void setGroups(List<Group> groups) {
		this.groups = groups;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public Map<String, Object> getMetadata() {
		return null;
	}

	public String getDuty() {
		return duty;
	}

	public void setDuty(String duty) {
		this.duty = duty;
	}

	public String getFkSysName() {
		return fkSysName;
	}

	public void setFkSysName(String fkSysName) {
		this.fkSysName = fkSysName;
	}

	public String toString() {
		return "companyId:" + companyId + ", name:" + username + ", administrator:" + administrator + ", enabled:"
				+ enabled;
	}

}